package com.shen.service;

import com.shen.dao.TrainDao;
import com.shen.entity.TrainInfo;
import com.shen.exception.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TrainServiceImpl implements TrainService {
    @Autowired
    private TrainDao trainDao;

    @Override
    public List<TrainInfo> getAllTrain() {
        return trainDao.getAllTrain();
    }

    @Override
    public TrainInfo findTrain(String no) {
        TrainInfo train = trainDao.findTrain(no);
        if(train==null){
            throw new NotFoundException();
        }
        return trainDao.findTrain(no);
    }

    @Override
    public int delTrain(String[] trainId) {
        return trainDao.delTrain(trainId);
    }
}
